<?php
require_once ('../../config/include_paths.php');
require_once('config.php');
require_once('dbconnect.php');	// database connect script.
$num_rows = 0;
if ($_POST) {
	$page_id = $_POST['page_id'];
	$enabled = $_POST['enabled'];
	$table = $_POST['table'];
}
	$query  = "SELECT * FROM $table
				WHERE page_id = $page_id and enabled = $enabled
				ORDER BY record_order ASC";

	$result = mysql_query($query);
	$num_rows = mysql_num_rows($result);
	
	if ($enabled == 0 && $num_rows > 0) {echo "<h3 class='disabledHeader'>Disabled</h3>";}
	while($row = mysql_fetch_array($result, MYSQL_ASSOC))
	{
?>
<li id="recordsArray_<?php echo $row['id']; ?>" class="ui-sortable">
		
  <span class="edit" id="<?php echo $row['id'];?>_title"><?php echo $row['title'];?></span>
  <?php if ($table == 'links') { ?>
  	<span class="edit" id="<?php echo $row['id'];?>_url"><?php echo $row['url'];?></span>
  <?php } ?>
  <?php if ($table == 'meeting_resources') {?>
  	<span id="<?php echo $row['id'];?>" class="ajaxupload"><?php echo $row['file'];?></span>
  <?php } ?>
  <?php if ($table == 'modules') {
	  echo '<div class="module">'.$row['editHTML'].'</div>'; 
	  ?>
   <label>ebabled? </label><input name="enabled<?php echo $table; ?>" type="checkbox" value="<?php echo $enabled?>" <?php if ($enabled == 1) echo 'checked="yes"'?>>
  <span class="editModule">
  	<a href="moduleform.php?id=<?php echo $row['id']; ?>" title="Edit"><img src="../images/edit_button.png" /></a>
    <a href="deleteform.php?id=<?php echo $row['id']; ?>&table=<?php echo $table; ?>&returnTo=<?php echo $ifDeleteReturnTo ?>" title="Delete"><img src="../images/delete_button.png" /></a>
  </span><?php } ?>
</li>
<?php } ?>